﻿@model Wei.Model.Content_Model
@using Wei.Model;
@{
    string user_id = "";
    if (Session["User_Info"] != null)
    {
        user_id = ((User_Model)Session["User_Info"]).u_id.ToString();
    }
}
@{
    ViewBag.Title = @Model.c_title;
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<link href="~/Content/wei_css.css" rel="stylesheet" />
<style>
    .content_type button {
        margin: 5px 0;
    }

    .good_color {
        font-size: 60px;
        color: #1E9FFF;
    }

    .no_good_color {
        font-size: 60px;
        color: #eee;
    }
</style>
<div class="layui-row layui-col-space15">
    <div class="layui-col-md9 content detail">
        <div class="fly-panel detail-box" style="margin: 10px 0;">
            <h1>@Model.c_title</h1>
            <div class="fly-detail-info">
                类别：<span class="layui-badge layui-bg-green fly-detail-column"> @Model.c_type_name </span>
                &nbsp;&nbsp;&nbsp;&nbsp;
                发布时间： <span>@string.Format("{0:yyyy-MM-dd HH:mm}", Model.c_create_date)</span>
                <div class="fly-admin-box" data-id="24545"> </div>
                <span class="fly-list-nums">
                    <i class="layui-icon" title="查看数量" style="font-size: 22px; color: #1E9FFF;">&#xe643;</i>@Model.c_read_num
                    <i class="layui-icon" title="点赞数量" style="font-size: 22px; color: #1E9FFF;">&#xe6c6;</i>@Model.c_good
                </span>
            </div>
            <fieldset class="layui-elem-field layui-field-title" style="text-align: center;"> <legend>文章详情</legend> </fieldset>
            <div class="detail-body layui-text photos" style="overflow: overlay;">
                @Html.Raw(Model.c_content)
            </div>
            <hr />
            <div style="margin:auto 0;text-align:center;">

                @if (Model.have_good != 0)
                {
                    <i id="i_good" onclick="layer.msg('您已经点过赞了！')" class="layui-icon good_color">&#xe6c6;</i>
                }
                else
                {
                    <i onclick="Add_Good()" id="i_good" class="layui-icon no_good_color">&#xe6c6;</i>
                }

            </div>
        </div>


        @if (Session["sy_show_comment"] != null)
        {
            if (Session["sy_show_comment"].ToString() == "是")
            {
                <div class="fly-panel detail-box" id="flyReply">
                    <fieldset class="layui-elem-field layui-field-title" style="text-align: center;"> <legend>评论</legend> </fieldset>
                    <!--评论的部分页-->
                    <div id="comment_div">
                        @Html.Action("Comment_List", "Home", new { c_id = Model.c_id })
                    </div>
                    <div class="layui-form layui-form-pane">
                        <div class="layui-form-item layui-form-text">
                            <div class="layui-input-block">
                                <textarea id="c_comment" name="L_comment" required="" lay-verify="required" placeholder="请输入内容" class="layui-textarea fly-editor" maxlength="300" style="height: 150px;"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <button class="layui-btn" onclick="Submit_Comment()">提交</button>
                        </div>
                    </div>
                </div>
            }
        }
            </div>

            <div class="layui-col-md3">
                <!--标签类别的部分页-->
                @Html.Action("Content_Type_List", "Home")
            </div>
  
</div>

<script>


    function Submit_Comment() {
        if ("@user_id" == "") {
            layer.msg("请先登录！");
            return;
        }
        var c_comment_text = $("#c_comment").val();
        if (c_comment_text == "") {
            layer.msg("请输入评论内容！");
            return;
        }
        if (c_comment_text.length < 50) {
            layer.msg('写多一点呗。50个字就够了 ^_^', { icon: 6 });
            return;
        }
        layer.load(1);
        $.post_str("/Content/Submit_Comment", { comment_content_id: "@Model.c_id", comment_user_id: "@user_id", comment_content: c_comment_text }, function (data) {
            layer.closeAll('loading');
            if (data == "1") {
                layer.msg("评论成功");
                refresh_comment();
            } else {
                layer.msg("评论失败，请重试");
            }
        });
    }

    function refresh_comment() {
        $.post_str("/Home/Comment_List", { c_id: "@Model.c_id", }, function (data) {
            $("#comment_div").html("");
            $("#comment_div").html(data);
            $("#c_comment").val("");
        });
    }

    function Add_Good() {
        if ("@user_id" == "") {
            layer.msg("请先登录！");
            return;
        }
        if ($("#i_good").hasClass('good_color')) {
            return;
        }
        layer.load(1);
        $.post_str("/Content/Add_Good", { c_id: "@Model.c_id" }, function (data) {
            layer.closeAll('loading');
            if (data == "1") {
                $("#i_good").removeClass("no_good_color");
                $("#i_good").addClass("good_color");
                $("#i_good").unbind("click");
                layer.msg("点赞成功");
            }
        });
    }
</script>